package codeTop;

public class q121 {
    public int maxProfit(int[] prices) {
        int min = 0x3ffffff;
        int max = 0;
        for (int i = 0; i < prices.length; i++) {
            max = Math.max(max,prices[i]-min);
            min = Math.min(min,prices[i]);
        }
        return max;
    }
}
